
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
	
<<<<<<< HEAD
	private int n;
	private int m;
	
	private int[][] food;
	/*
	 * define three Adjacent directions
	 * while contian down、up、right
	 */
	int[][] dir={{1,0},{-1,0},{0,1}};
	
	/*
	 * read input data
	 */
	public void Input(){
		Scanner input=new Scanner(System.in);
		n=input.nextInt();
		m=input.nextInt();
		if(n==0 || m==0)
=======
	private List<String> ans;
	private int end;
	private boolean[] vis;
	private int size;
	
	public void dfs(int[] rec,int n){
		if(end==0)
>>>>>>> 32b807a3191a63c9921894f99113675c09055120
			return ;
		int i;
		int x=0;
<<<<<<< HEAD
		x++;
	}
	
	/*
	 * dp[i][j][3]，i、j represent the location in the board, and 3th dimension
	 * represent the three coming state best score,while are from the Adjacent down、up、left position
	 */
	public int solved(){
		int i,j,k;
		int[][][] dp=new int[n+1][m+1][3];
		
=======
		StringBuilder sb=new StringBuilder();
>>>>>>> 32b807a3191a63c9921894f99113675c09055120
		for(i=0;i<n;i++){
			x*=10;
			x+=rec[i];
			sb.append(rec[i]);
		}
<<<<<<< HEAD
		for(i=1;i<=m;i++){
			/*
			 * handle the ith row
			 */
			for(j=0;j<n;j++){
				dp[j][i][0]=-1;
				dp[j][i][1]=-1;
				dp[j][i][2]=-1;
				if(food[j][i-1]!=-1){
					dp[j][i][0]=dp[j][i-1][0]+food[j][i-1];
				}
			}
			/*
			 * update dp[j][i][1]=max(dp[j-1][i][1]+food[j][i],dp[j-1][i-1][0]+food[j][i]);
			 * coming from the left position or the up position
			 */
			for(j=0;j<n;j++){
				//the position [i][j] is allowed to be passed
				if(food[j][i-1]!=-1){
					dp[j][i][1]=dp[j][i][0];
					if(j==0){
						/*
						 * from the (n-1)th row down to this position
						 */
						if(food[n-1][i-1]!=-1 && dp[n-1][i][0]!=-1){
							dp[j][i][1]=max(food[j][i-1],dp[j][i][0]);
						}
					}
					else{
						/*
						 * choose the larger value from up position or the left position
						 */
						if(food[j-1][i-1]!=-1){
							dp[j][i][1]=max(food[j][i-1]+dp[j-1][i][1],dp[j][i][0]);
						}
					}
				}
			}
			/*
			 * update dp[j][i][2] which is from the left or the down direction
			 */
			for(j=n-1;j>=0;j--){
				//down direction is allowed to be passed
				if(food[j][i-1]!=-1){
					//suppose comming from the left direction
					dp[j][i][2]=dp[j][i][0];
					if(j==n-1){
						/*
						 * from the 0th row up to transport the （n-1）th row,update dp[j][i]
						 */
						if(food[0][i-1]!=-1 && dp[0][i][0]!=-1){
							dp[j][i][2]=max(food[j][i-1],dp[j][i][0]);
						}
					}
					else{
						/*
						 * dp[j][i][2] choose the larger which is from the down direction or the left direction
						 */
						if(food[j+1][i-1]!=-1){
							dp[j][i][2]=max(food[j][i-1]+dp[j+1][i][2],dp[j][i][0]);
						}
					}
				}
			}
			/*
			 * update dp[i][j][0] =max{dp[i][j][↓]，dp[i][j][↑]},make the dp[i][j][0] to be the max score 
			 * from the three direction
			 */
			for(j=0;j<n;j++){
				dp[j][i][0]=max(dp[j][i][1],dp[j][i][2]);
			}
		}
		int maxFood=-1;
		/*
		 * find the best score which is in the (m-1)th column 
		 */
		for(i=0;i<n;i++){
			if(maxFood<dp[i][m][0]){
				maxFood=dp[i][m][0];
=======
		ans.add(sb.toString());
		end--;
		vis[x]=true;
		for(i=0;i<n;i++){
			int t=rec[i];
			t++;
			if(t>9)
				t=0;
			int y=0;
			for(int j=0;j<i;j++){
				y*=10;
				y+=rec[j];
			}
			y*=10;
			y+=t;
			for(int j=i+1;j<n;j++){
				y*=10;
				y+=rec[j];
			}
			if(y>=0 && y<size && !vis[y]){
				rec[i]=t;
				dfs(rec,n);
				break;
			}
			t=rec[i];
			t--;
			if(t<0)	
				t=9;
			y=0;
			for(int j=0;j<i;j++){
				y*=10;
				y+=rec[j];
			}
			y*=10;
			y+=t;
			for(int j=i+1;j<n;j++){
				y*=10;
				y+=rec[j];
			}
			if(y>=0 && y<size && !vis[y]){
				rec[i]=t;
				dfs(rec,n);
				break;
>>>>>>> 32b807a3191a63c9921894f99113675c09055120
			}
		}
	}
	
	public void solved(int n){
		end=1;
		for(int i=0;i<n;i++){
			end*=10;
		}
		size=end;
		vis=new boolean[end+1];
		ans=new ArrayList<String>();
		int[] rec=new int[n];
		for(int i=0;i<n;i++)
			rec[i]=0;
		
		dfs(rec,n);
		System.out.println(size-1);
		for(int i=0;i<ans.size();i++){
			System.out.println(ans.get(i));
		}
		System.out.println();
	}
	public static void main(String[] args){

		Scanner input=new Scanner(System.in);
		int n;
		n=input.nextInt();
		Main mm=new Main();
		mm.solved(n);
	}
}
